<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class HospitalUserFamily extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'eb_hospital_user_family';
    public $timestamps = false;
    protected $fillable = [
        'user_id',
        'family_id',
        'hospital_team_id',
        'hospital_id',
        'created_at',
        'type',
        'is_sign',
        'endtime',
        'starttime',
        'status',
        'type',
        'user_id',
        'family_id',
        'family_pregn_id',
    ];

    public static $typeTxt = [
        1=>'儿童',
        2=>'孕妇'
    ];

    public static $statusTxt = [
        0=>'已解约',
        1=>'签约中',
        2=>'已完成'
    ];
    public static $isSignTxt = [
        0=>'否',
        1=>'是',
    ];
    public function family(){
        return $this->hasOne(Family::class,'id','family_id');
    }
    public function preg(){
        return $this->hasOne(FamilyPregn::class,'family_id','family_id');
    }
    public function familyChild(){
        return $this->hasOne(FamilyChild::class,'id','family_id');
    }
    public function hospital(){
        return $this->hasOne(Hospital::class,'id','hospital_id');
    }
    public function user(){
        return $this->hasOne(User::class,'id','user_id');
    }
    public function team(){
        return $this->hasOne(HospitalTeam::class,'id','hospital_team_id');
    }
    public function import()
    {
        return $this->hasMany(ImportFamily::class,'family_id','family_id');
    }
}
